---
title: JSON Reader
---

The **JSON Reader** processes JSON files and converts them into documents that can be used with Agno's knowledge system.

## Code

```python examples/concepts/knowledge/readers/json_reader.py
import json
from pathlib import Path

from agno.knowledge.reader.json_reader import JSONReader

reader = JSONReader()

json_path = Path("tmp/test.json")
test_data = {"key": "value"}
json_path.write_text(json.dumps(test_data))

try:
    print("Starting read...")
    documents = reader.read(json_path)

    if documents:
        for doc in documents:
            print(doc.name)
            print(doc.content)
            print(f"Content length: {len(doc.content)}")
            print("-" * 80)
    else:
        print("No documents were returned")

except Exception as e:
    print(f"Error type: {type(e)}")
    print(f"Error occurred: {str(e)}")
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install libraries">
    ```bash
    pip install -U agno openai
    ```
  </Step>

  <Step title="Set environment variables">
    ```bash
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Step title="Run Agent">
    <CodeGroup>
    ```bash Mac
    python examples/concepts/knowledge/readers/json_reader.py
    ```

    ```bash Windows
    python examples/concepts/knowledge/readers/json_reader.py
    ```
    </CodeGroup>
  </Step>
</Steps>

## Params

<Snippet file="json-reader-reference.mdx" />

